/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test_cv;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 *
 * @author acappon
 */
public class CTargetInfo
{

    CTarget m_currentTarget;
    Date m_timestamp;
    ArrayList<CTarget> m_listOfTarget;

    void init()
    {
        m_listOfTarget.removeAll(m_listOfTarget);
    }

    String displayText()
    {
        String sRet;
        sRet = m_timestamp.toString() + "\n";
        for (int i = 0; i < m_listOfTarget.size(); i++)
        {
            sRet += m_listOfTarget.get(i).displayText();
        }
        return sRet;
    }

    void parse(String result)
    {
        int eolIndex = result.indexOf("\n");
        String strToken = result.substring(0, eolIndex);
        String remaining = result.substring(eolIndex);
        
        m_currentTarget.init();

        SimpleDateFormat ft = new SimpleDateFormat();
        try
        {
            m_timestamp = ft.parse(strToken);
            System.out.println(m_timestamp);
        } catch (ParseException e)
        {
            System.out.println("Unparseable using " + ft);
        }

        while (remaining.length()> 0)
        {
            strToken = remaining.substring(0, eolIndex);
            remaining = remaining.substring(eolIndex);
            m_currentTarget.parse(strToken);
            m_listOfTarget.add(m_currentTarget);
        }
    }
}
